package org.ufinity.hsms.module.device.entity;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ItemEntity {
	public String itemId;
	public String itemDesc;
	public int lastClock;
	public String lastValue;
	public String units;
	public String key;
	public boolean hasGraphData;
	
	
	public ItemEntity(JSONObject json) {
		if (json != null) {
			try {
				itemId = json.getString("itemid");
				itemDesc = json.getString("description");
				lastValue = json.getString("lasvalue");
				units = json.getString("units");
				key = json.getString("key");
				lastClock = json.getInt("lastclock");
				hasGraphData = json.getBoolean("hasgraphdata");
				
			} catch (JSONException jsone) {
				
			}
		}
	}
	
	public static ArrayList<ItemEntity> getList(String sendRequest)
			throws JSONException {
		ArrayList<ItemEntity> list = null;
		JSONArray jsonArray = new JSONArray(sendRequest);
		if (jsonArray != null && jsonArray.length() >= 0) {
			int length = jsonArray.length();
			list = new ArrayList<ItemEntity>(length);
			for (int i = 0; i < length; i++) {
				list.add(new ItemEntity(jsonArray.getJSONObject(i)));
			}
		}
		return list;
	}

	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public String getItemDesc() {
		return itemDesc;
	}

	public void setItemDesc(String itemDesc) {
		this.itemDesc = itemDesc;
	}

	public int getLastClock() {
		return lastClock;
	}

	public void setLastClock(int lastClock) {
		this.lastClock = lastClock;
	}

	public String getLastValue() {
		return lastValue;
	}

	public void setLastValue(String lastValue) {
		this.lastValue = lastValue;
	}

	public String getUnits() {
		return units;
	}

	public void setUnits(String units) {
		this.units = units;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public boolean isHasGraphData() {
		return hasGraphData;
	}

	public void setHasGraphData(boolean hasGraphData) {
		this.hasGraphData = hasGraphData;
	}
	
	
	
	
}
